package com.example;

//恶汉模式
public class HungrySingle {

    private static HungrySingle hungrySingle = new HungrySingle();

    private HungrySingle() {
    }

    public static HungrySingle getInstance() {
        return hungrySingle;
    }

}

class LazySingle {

    private static LazySingle single = null;

    private LazySingle() {

    }

    public static LazySingle getInstance() {
        if (single == null) {
            single = new LazySingle();
        }
        return single;
    }
}







